//
//  HZOrderPayWayHeaderView.m
//  app
//
//  Created by 刘华舟 on 15/5/6.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HZOrderPayWayHeaderView.h"



static const NSInteger kOrderCellMargin = 24;
static const NSInteger kArrowImageWidth = 40;

@interface HZOrderPayWayHeaderView()

@property (strong, nonatomic) UILabel *leftLabel;
@property (strong, nonatomic) UILabel *rightLabel;
@property (strong, nonatomic) UIButton* arrowBtn;


@end


@implementation HZOrderPayWayHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        self.frame = CGRectOf([UBO_SCREEN fx:UB_LEFT fy:UB_TOP], [UBO_SCREEN fw:UB_WIDTH oh:kHZOrderPayWayHeaderViewHeight]);
        //设置背景色
        self.backgroundColor = HZ_WHITE_COLOR;

        //左
        self.leftLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:kOrderCellMargin fy:UB_TOP],
                                                                 [self.ubo fw:UB_WIDTH uw:-2*kOrderCellMargin fh:UB_HEIGHT])];
        self.leftLabel.textAlignment = NSTextAlignmentLeft;
        self.leftLabel.textColor = HZ_MALL_TEXT_M_LIGHTGRAY_COLOR;
        self.leftLabel.font = kHZFont_Content_S;
        self.leftLabel.text = @"付款方式";
        self.leftLabel.backgroundColor = HZ_CLEAR_COLOR;
        [self addSubview:self.leftLabel];
        
        //右
        self.rightLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.ubo fx:UB_LEFT ux:kOrderCellMargin fy:UB_TOP],
                                                                  [self.ubo fw:UB_WIDTH uw:-2*kOrderCellMargin ow:-kArrowImageWidth/4 fh:UB_HEIGHT])];
        self.rightLabel.textAlignment = NSTextAlignmentRight;
        self.rightLabel.textColor = HZ_MALL_TEXT_M_LIGHTGRAY_COLOR;
        self.rightLabel.font = kHZFont_Content_S;
        self.rightLabel.backgroundColor = HZ_CLEAR_COLOR;
        [self.rightLabel setUserInteractionEnabled:YES];
        UITapGestureRecognizer *tapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(arrowBtnOnClick)];
        [self.rightLabel addGestureRecognizer:tapGes];
        
        [self addSubview:self.rightLabel];
        
        //查看详情右箭头
        self.arrowBtn = [[UIButton alloc] initWithFrame:CGRectOf([self.ubo fx:UB_RIGHT ux:-kOrderCellMargin ox:-kArrowImageWidth/4 fy:UB_TOP],
                                                                 [self.ubo ow:kArrowImageWidth/4 fh:UB_HEIGHT])];
        self.arrowBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [self.arrowBtn setImage:[UIImage imageNamed:kImageArrowRight] forState:UIControlStateNormal];
        [self.arrowBtn addTarget:self action:@selector(arrowBtnOnClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.arrowBtn];

    }
    
    return self;
}

- (void)arrowBtnOnClick{
    if(self.targetCallerPayWay){
        [self.targetCallerPayWay call];
    }
}


/** 更改支付方式 -write by khzliu */
- (void)changePayWayWithMessage:(NSString *)messgage netPay:(BOOL)netPay{
    _netPay = netPay;
    self.rightLabel.text = messgage;
}

@end
